<div class="delivery_bombbox">
    <div class="h_top"><h2>发货</h2><a class="close_box">×</a></div>
    <div class="fl shu_box">
        <span>物流公司</span>
        <select name="express_company" class="express_company">
            @foreach($express_company as $k => $v)
            <option value="{{$k}}">{{$v}}</option>
            @endforeach
        </select>
    </div>
    <div class="fl shu_box">
        <span>物流单号</span>
        <input type="text" name="waybill_number" class="waybill_number">
        <p class="jm_error"></p>
    </div>
    <div class="fl shu_box">
        <span>物流类型</span>
        <select name="type" class="type">
            <option value="1">物流</option>
            <option value="2">快递</option>
            <option value="3">自送</option>
            <option value="4">自提</option>
        </select>
    </div>
    <div class="btn_box">
        <div class="btn_cancel fr close_box">取消</div>
        {{-- data-id由触发弹窗的事件塞值 --}}
        <div class="btn_confirm fr delivery_confirm express_confirm" data-id="" data-url="">确定</div>
    </div>
</div>

<script>
var shipments_url = '/member/seller/orders/{id}/order_express'

$('.close_box').click(function(){
    $('.bg_h').hide();
    $('.delivery_bombbox').hide();
});

$('.express_confirm').click(function(){
//    event.preventDefault();

    var waybill_number = $('.waybill_number').val();
    var type = $('.type option:selected').val();
    var company_code = $('.express_company option:selected').val();
    var express_company = $('.express_company option:selected').text();

    var order_id = $('.express_confirm').data('id');
    var url = shipments_url.replace('{id}', order_id);

    $.ajax({
        url: url,
        type: 'POST',
        dataType: 'json',
        data: {'type': type, 'company_code': company_code, 'express_company': express_company, 'waybill_number': waybill_number},
        success: function (data) {
            if (0 == data.code) {
                layer.alert("发货成功", {
                    icon: 1
                }, function () {
                    location.reload();
                });
            } else {
                layer.alert(data.message, {
                    icon: 2
                });
            }
        }
    });
});
</script>